package com.openweixin.sheknows.domain;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 * 实体类-会员提问
 * 
 * @注意事项 无
 * @author 刘思作
 * @version 1.0.0 2014-04-02
 * @since 1.0.0
 */

@Entity
@Table(name = "question")
public class Question implements Serializable {

	private static final long serialVersionUID = 4875398853136034706L;
	private Integer qid;// id
	private User user;//
	private String author;// 提问者名称
	private String subject;// 问题标题
	private String content;// 问题内容
	private String useip;// 用户ip
	private Integer status;// 状态 -1 锁定，0未解决，1已解决 ,2以查看解决的答案
//	private Integer readStatus;//是否查看回答( 2未查看,1以查看,只有status=1时此字段才有用 默认1 )
	private Integer lockExpert;//锁定的专家
	private Boolean score;// 最终的评分，如果有
	private Integer rqid;// 问题的引用
	private java.sql.Timestamp datetime;//
	private List<Answer> answers=new ArrayList<Answer>(0);

//	ALTER TABLE `question`
//	ADD COLUMN `lock_extpert`  int NULL AFTER `rqid`;


	
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name = "qid")
	public Integer getQid() {
		return this.qid;
	}

	public void setQid(Integer qid) {
		this.qid = qid;
	}
	@ManyToOne
	@JoinColumn(name = "uid")
	public User getUser() {
		return this.user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@Column(name = "author")
	public String getAuthor() {
		return this.author;
	}

	public void setAuthor(String author) {
		this.author = author;
	}

	@Column(name = "subject")
	public String getSubject() {
		return this.subject;
	}

	public void setSubject(String subject) {
		this.subject = subject;
	}

	@Column(name = "content")
	public String getContent() {
		return this.content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	@Column(name = "useip")
	public String getUseip() {
		return this.useip;
	}

	public void setUseip(String useip) {
		this.useip = useip;
	}

	@Column(name = "status")
	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	@Column(name = "score")
	public Boolean getScore() {
		return score;
	}
	

	public void setScore(Boolean score) {
		this.score = score;
	}

	@Column(name = "rqid")
	public Integer getRqid() {
		return this.rqid;
	}

	public void setRqid(Integer rqid) {
		this.rqid = rqid;
	}

	@Column(name = "datetime")
	public java.sql.Timestamp getDatetime() {
		return this.datetime;
	}

	public void setDatetime(java.sql.Timestamp datetime) {
		this.datetime = datetime;
	}

	
	@OneToMany(mappedBy="question")
	@OrderBy(value="aid desc")
	public List<Answer> getAnswers() {
		return answers;
	}

	public void setAnswers(List<Answer> answers) {
		this.answers = answers;
	}

	@Column(name="lock_extpert")
	public Integer getLockExpert() {
		return lockExpert;
	}

	public void setLockExpert(Integer lockExpert) {
		this.lockExpert = lockExpert;
	}

	private boolean newAnswer;

	@Transient
	public boolean isNewAnswer() {
		return newAnswer;
	}

	public void setNewAnswer(boolean newAnswer) {
		this.newAnswer = newAnswer;
	}
	
	
}